<template>
	<div id="account_center">
		<el-radio-group class="headradioBtn_type" v-model="headradioBtn_type.radio"   @change="headradioBtnchange_type">
			<el-radio-button label="account" class="first">账户中心</el-radio-button>
			<el-radio-button label="charge">充值明细</el-radio-button>
			<el-radio-button label="pay">支出明细</el-radio-button>
			<el-radio-button label="refund" :class="userLevel==2?'last':''">退款明细</el-radio-button>
			<el-radio-button v-show="userLevel==1" label="allorders" class="last">全部订单</el-radio-button>
		</el-radio-group>
		<!-- <div class="main-title">{{mainTitle}}</div> -->
		<div class="box-chargeForSchool" v-show="headradioBtn_type.radio=='account'">
			<div class="box-accountMoney">
				<span style="font-size:0.22rem;width: 100%;padding-left: 0.08rem;">账户余额</span>
				<span style="font-size:0.48rem;">￥{{accountObj.accountMoney}}</span>
			</div>
			<div class="box-payBtn">
				<el-button v-show="userLevel==1" v-if="hasApi('chargeForCampusAccount')" @click="showSchoolRecharge">校区充值</el-button>
			</div>
		</div>
		<div class="content" v-show="headradioBtn_type.radio!='allorders'">
			<div class="headmenu">
				<!-- 账户中心 -->
				<div class="box-innerPane" v-show="headradioBtn_type.radio=='account'">
					<div class="row" style="margin-top:0rem;" v-show="userLevel==1">
						<div class="row" style="display:flex;justify-content: space-between;align-items: center;margin-bottom: 0.25rem;">
							<span style="color:#333333;font-size:0.2rem;font-weight:bold;">各校区账户余额</span>
							<div>
								<el-input class="comSearchInput" v-model="accountObj.organization.searchParam.generalTerm"
									clearable  style="width:3rem;" placeholder="搜索 校区名、校长、手机号">
								</el-input>
								<div style="margin-left:0.1rem;" class="search_btn" 
								@click="apiQuerySchoolsMoney(1)">搜索</div>
							</div>
						</div>
						<div class="row" >
							<el-table
								:data="accountObj.organization.tableData"
								stripe
								style="width: 100%">
								<el-table-column
								prop="updateTime"
								align="center"
								label="日期">
								</el-table-column>
								<el-table-column
								prop="name"
								align="center"
								label="校区">
								</el-table-column>
								<el-table-column
								prop="accountMoney"
								align="center"
								label="校区账户余额">
								</el-table-column>
								<el-table-column
								label="操作"
								align="center">
								<template slot-scope="scope">
									<el-button @click="showSchoolAccountDetail(scope.row)" type="text" size="small">详情</el-button>
								</template>
								</el-table-column>
							</el-table>
						</div>
						<div class="row">
							<el-pagination
								:page-sizes="[10, 20, 30, 40,50,100]"
								:page-size="accountObj.organization.searchParam.pageSize"
								layout="total, sizes, prev, pager, next, jumper"
								:total="accountObj.organization.searchParam.total"
								:current-page="accountObj.organization.searchParam.currPage"
								@current-change="schoolListCurrentPageChange"
								@size-change="schoolListSizeChange">
							</el-pagination>
						</div>
					</div>
					<div class="row" style="margin-top:0rem;" v-show="userLevel==2">
						<div class="row" style="margin-bottom: 0.25rem;">
							<span style="color:#333333;font-size:0.2rem;font-weight:bold;">近期充值记录</span>
						</div>
						<div class="row" >
							<el-table
								:data="campusAccountRecordCommData.tableData"
								stripe
								style="width: 100%">
								<el-table-column
								prop="accountDate"
								align="center"
								label="充值日期">
								</el-table-column>
								<el-table-column
								prop="accountMoney"
								align="center"
								label="金额">
								</el-table-column>
								<el-table-column
								prop="accountPayMode"
								align="center"
								label="充值方式">
									<template slot-scope="scope">
										{{accountPayModeMatch[scope.row.accountPayMode]}}
									</template>
								</el-table-column>
								<el-table-column
								prop="accountNo"
								align="center"
								label="交易号">
								</el-table-column>
								<el-table-column
								prop="createUserName"
								align="center"
								label="操作人">
								</el-table-column>
							</el-table>
						</div>
						<div class="row" style="text-align:center;">
							<el-pagination
								:page-sizes="[10, 20, 30, 40,50,100]"
								:page-size="campusAccountRecordSearchParam.pageSize"
								layout="total, sizes, prev, pager, next, jumper"
								:total="campusAccountRecordCommData.paginationtotal"
								:current-page="campusAccountRecordSearchParam.currPage"
								@current-change="commCurrentPageChange"
								@size-change="commhandleSizeChange">
							</el-pagination>
						</div>
					</div>
				</div>
				<!-- 充值明细 -->
				<div class="box-innerPane" v-show="headradioBtn_type.radio=='charge'">
					<div class="row">
						<el-select class="comSearchInput" filterable v-show="userLevel==1" clearable @change="commSelectSchool"
						 v-model="selectSchoolComm" placeholder="所有校区">
							<el-option
							v-for="item in schoolNameOptionsComm"
							:key="item.value"
							:label="item.label"
							:value="item.value">
							</el-option>
						</el-select>
						<el-date-picker
							class="comSearchInput"
							v-model="selectTimeComm"
							type="datetimerange"
							range-separator="至"
							align="center"
							start-placeholder="开始日期"
							end-placeholder="结束日期"
							@change="changeTimeComm"
							:default-time="['00:00:00', '00:00:00']">
						</el-date-picker>
						<!-- <el-button @click="()">查询</el-button> -->
						<div class="search_btn" v-if="hasApi('queryCampusAccountRecord')" @click="apiQueryCampusAccountRecord()">搜索</div>
					</div>
					<div class="row" style="margin-top:0.16rem;" v-show="userLevel==1">
						<el-table
							:data="campusAccountRecordCommData.tableData"
							stripe
							style="width: 100%">
							<el-table-column
							prop="accountDate"
							align="center"
							label="充值日期">
							</el-table-column>
							<el-table-column
							label="充值金额"
							align="center">
							<template slot-scope="scope">
								<span style="color:rgb(25, 177, 13);">{{'+￥'+scope.row.accountMoney}}</span>
							</template>
							</el-table-column>
							<el-table-column
							prop="campusMoney"
							align="center"
							label="校区余额">
							</el-table-column>
							<el-table-column
							prop="accountPayMode"
							align="center"
							label="充值方式">
								<template slot-scope="scope">
									{{accountPayModeMatch[scope.row.accountPayMode]}}
								</template>
							</el-table-column>
							<el-table-column
							prop="createUserName"
							align="center"
							label="操作人">
							</el-table-column>
							<el-table-column
							prop="accountNo"
							align="center"
							label="交易号">
							</el-table-column>
							<el-table-column
							prop="campusName"
							align="center"
							label="校区">
							</el-table-column>
						</el-table>
					</div>
					<div class="row" style="margin-top:0.16rem;" v-show="userLevel==2">
						<el-table
							:data="campusAccountRecordCommData.tableData"
							stripe
							style="width: 100%">
							<el-table-column
							prop="accountDate"
							align="center"
							label="充值日期">
							</el-table-column>
							<el-table-column
							label="充值金额"
							align="center">
							<template slot-scope="scope">
								<span style="color:rgb(25, 177, 13);">{{'+￥'+scope.row.accountMoney}}</span>
							</template>
							</el-table-column>
							<el-table-column
							prop="accountPayMode"
							align="center"
							label="充值方式">
								<template slot-scope="scope">
									{{accountPayModeMatch[scope.row.accountPayMode]}}
								</template>
							</el-table-column>
							<el-table-column
							prop="accountNo"
							align="center"
							label="交易号">
							</el-table-column>
							<el-table-column
							prop="createUserName"
							align="center"
							label="操作人">
							</el-table-column>
						</el-table>
					</div>
					<div class="row" style="text-align:center;">
						<el-pagination
							:page-sizes="[10, 20, 30, 40,50,100]"
							:page-size="campusAccountRecordSearchParam.pageSize"
							layout="total, sizes, prev, pager, next, jumper"
							:total="campusAccountRecordCommData.paginationtotal"
							:current-page="campusAccountRecordSearchParam.currPage"
							@current-change="commCurrentPageChange"
							@size-change="commhandleSizeChange">
						</el-pagination>
					</div>
				</div>
				<!-- 支出明细 -->
				<div class="box-innerPane" v-show="headradioBtn_type.radio=='pay'">
					<div class="row">
						<el-select class="comSearchInput" filterable v-show="userLevel==1" clearable @change="commSelectSchool"
						 v-model="selectSchoolComm" placeholder="所有校区">
							<el-option
							v-for="item in schoolNameOptionsComm"
							:key="item.value"
							:label="item.label"
							:value="item.value">
							</el-option>
						</el-select>
						<el-input class="comSearchInput" v-show="userLevel==2" v-model="payObj.inputClassName"  @change="selectClassName"
						 clearable placeholder="输入班级名称" style="width:3rem;"></el-input>
						<el-date-picker
							class="comSearchInput"
							v-model="selectTimeComm"
							type="datetimerange"
							range-separator="至"
							align="center"
							start-placeholder="开始日期"
							end-placeholder="结束日期"
							@change="changeTimeComm"
							:default-time="['00:00:00', '00:00:00']">
						</el-date-picker>
						<!-- <el-button @click="()">查询</el-button> -->
						<div class="search_btn" v-if="hasApi('queryCampusAccountRecord')" @click="apiQueryCampusAccountRecord()">搜索</div>
					</div>
					<div class="row" style="margin-top:0.16rem;" v-show="userLevel==1">
						<el-table
							:data="campusAccountRecordCommData.tableData"
							stripe
							style="width: 100%">
							<el-table-column
							align="center"
							width="220"
							label="订单号">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.orderNo}}
								</template>
							</el-table-column>
							<el-table-column
							prop="campusName"
							align="center"
							label="所属校区">
							</el-table-column>
							<el-table-column
							align="center"
							label="购买课程">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.courseName}}
								</template>
							</el-table-column>
							<el-table-column
							align="center"
							label="教师类型">
								<template slot-scope="scope">
									{{foreignTeacherTypeMatch[scope.row.acOrderEntity.foreignTeacherType]}}
								</template>
							</el-table-column>
							<el-table-column
							prop="courseCountAll"
							align="center"
							label="总购课(节)">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.syllabusNum}}
								</template>
							</el-table-column>
							<el-table-column
							prop="courseCount"
							align="center"
							label="本次购(节)">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.buySyllabusNum}}
								</template>
							</el-table-column>
							<el-table-column
							prop="accountMoney"
							align="center"
							label="实际支付">
							</el-table-column>
							<el-table-column
							prop="accountDate"
							align="center"
							label="支付时间">
							</el-table-column>
							<!-- <el-table-column
							label="操作"
							prop="operation"
							align="center">
							<template slot-scope="scope">
								<el-button @click="payRefundDetail(scope.row)" type="text">订单详情</el-button>
							</template>
							</el-table-column> -->
						</el-table>
					</div>
					<div class="row" style="margin-top:0.16rem;" v-show="userLevel==2">
						<el-table
							:data="campusAccountRecordCommData.tableData"
							stripe
							style="width: 100%">
							<el-table-column
							prop="accountDate"
							align="center"
							label="支出日期">
							</el-table-column>
							<el-table-column
							align="center"
							width="220"
							label="订单号">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.orderNo}}
								</template>
							</el-table-column>
							<el-table-column
							align="center"
							label="购买课程">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.courseName}}
								</template>
							</el-table-column>
							<el-table-column
							align="center"
							label="教师类型">
								<template slot-scope="scope">
									{{foreignTeacherTypeMatch[scope.row.acOrderEntity.foreignTeacherType]}}
								</template>
							</el-table-column>
							<el-table-column
							prop="courseCountAll"
							align="center"
							label="总购课(节)">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.syllabusNum}}
								</template>
							</el-table-column>
							<el-table-column
							align="center"
							label="本次购(节)">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.buySyllabusNum}}
								</template>
							</el-table-column>
							<el-table-column
							prop="accountMoney"
							align="center"
							label="支出金额">
							</el-table-column>
							<el-table-column
							prop="accountPayMode"
							align="center"
							label="支出方式">
								<template slot-scope="scope">
									余额支付
									<!-- {{accountPayModeMatch[scope.row.accountPayMode]}} -->
								</template>
							</el-table-column>
							<el-table-column
							prop="acOrderEntity.createUserName"
							align="center"
							label="操作人">
							</el-table-column>
						</el-table>
					</div>
					<div class="row" style="text-align:center;">
						<el-pagination
							:page-sizes="[10, 20, 30, 40,50,100]"
							:page-size="campusAccountRecordSearchParam.pageSize"
							layout="total, sizes, prev, pager, next, jumper"
							:total="campusAccountRecordCommData.paginationtotal"
							:current-page="campusAccountRecordSearchParam.currPage"
							@current-change="commCurrentPageChange"
							@size-change="commhandleSizeChange">
						</el-pagination>
					</div>
				</div>
				<!-- 退费明细 -->
				<div class="box-innerPane" v-show="headradioBtn_type.radio=='refund'">
					<div class="row">
						<el-select v-show="userLevel==1" filterable clearable @change="commSelectSchool"
						 class="comSearchInput"
						 v-model="selectSchoolComm" placeholder="所有校区">
							<el-option
							v-for="item in schoolNameOptionsComm"
							:key="item.value"
							:label="item.label"
							:value="item.value">
							</el-option>
						</el-select>
						<el-input v-show="userLevel==2" v-model="refundObj.inputClassName" @change="selectClassName" class="comSearchInput"
						 clearable placeholder="输入班级名称" style="width:3rem;"></el-input>
						<el-date-picker
							class="comSearchInput"
							v-model="selectTimeComm"
							type="datetimerange"
							range-separator="至"
							align="center"
							start-placeholder="开始日期"
							end-placeholder="结束日期"
							@change="changeTimeComm"
							:default-time="['00:00:00', '00:00:00']">
						</el-date-picker>
						<!-- <el-button @click="()">查询</el-button> -->
						<div class="search_btn" v-if="hasApi('queryCampusAccountRecord')" @click="apiQueryCampusAccountRecord()">搜索</div>
					</div>
					<div class="row" style="margin-top:0.16rem;" v-show="userLevel==1">
						<el-table
							:data="campusAccountRecordCommData.tableData"
							stripe
							style="width: 100%">
							<el-table-column
							align="center"
							width="220"
							label="订单号">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.orderNo}}
								</template>
							</el-table-column>
							<el-table-column
							prop="campusName"
							align="center"
							label="所属校区">
							</el-table-column>
							<el-table-column
							align="center"
							label="退款课程">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.courseName}}
								</template>
							</el-table-column>
							<el-table-column
							prop="courseCountAll"
							align="center"
							label="退课数(节)">
								<template slot-scope="scope">
									{{scope.row.acOrderRefundEntity.syllabusNum}}
								</template>
							</el-table-column>
							<el-table-column
							prop="accountMoney"
							align="center"
							label="退款金额">
							</el-table-column>
							<el-table-column
							prop="accountDate"
							align="center"
							label="退款时间">
							</el-table-column>
							<!-- <el-table-column
							label="操作"
							prop="operation"
							align="center">
							<template slot-scope="scope">
								<el-button  @click="payRefundDetail(scope.row)" type="text">订单详情</el-button>
							</template>
							</el-table-column> -->
						</el-table>
					</div>
					<div class="row" style="margin-top:0.16rem;" v-show="userLevel==2">
						<el-table
							:data="campusAccountRecordCommData.tableData"
							stripe
							style="width: 100%">
							<el-table-column
							align="center"
							width="220"
							label="订单号">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.orderNo}}
								</template>
							</el-table-column>
							<el-table-column
							align="center"
							label="退款课程">
								<template slot-scope="scope">
									{{scope.row.acOrderEntity.courseName}}
								</template>
							</el-table-column>
							<el-table-column
							align="center"
							label="退课数(节)">
								<template slot-scope="scope">
									{{scope.row.acOrderRefundEntity.syllabusNum}}
								</template>
							</el-table-column>
							<el-table-column
							prop="accountMoney"
							align="center"
							label="退款金额">
							</el-table-column>
							<el-table-column
							prop="accountDate"
							align="center"
							label="退款时间">
							</el-table-column>
							<el-table-column
								prop="createUserName"
								align="center"
								label="操作人">
							</el-table-column>
						</el-table>
					</div>
					<div class="row" style="text-align:center;">
						<el-pagination
							:page-sizes="[10, 20, 30, 40,50,100]"
							:page-size="campusAccountRecordSearchParam.pageSize"
							layout="total, sizes, prev, pager, next, jumper"
							:total="campusAccountRecordCommData.paginationtotal"
							:current-page="campusAccountRecordSearchParam.currPage"
							@current-change="commCurrentPageChange"
							@size-change="commhandleSizeChange">
						</el-pagination>
					</div>
				</div>
			
			</div>
		</div>
		<!-- 全部订单 -->
		<div class="content allorders" style="margin-top:-0.25rem;" v-show="headradioBtn_type.radio=='allorders'">
			<div class="headmenu">
				<div class="box-innerPane">
					<div class="row">
						<el-radio-group class="orderType" v-model="allordersObj.orderType" @change="allorderChangeType">
							<el-radio-button label="交易成功">交易成功</el-radio-button>
							<el-radio-button label="支付成功">支付成功</el-radio-button>
							<el-radio-button label="退款订单">退款订单</el-radio-button>
						</el-radio-group>
					</div>
					<div class="orderObj searchbox" style="">
						<div>
							<el-select filterable style="width:1.5rem;" clearable @change="commSelectSchool" class="comSearchInput"
							 v-model="selectSchoolComm" placeholder="所有校区">
								<el-option
								v-for="item in schoolNameOptionsComm"
								:key="item.value"
								:label="item.label"
								:value="item.value">
								</el-option>
							</el-select>
							<el-date-picker
								class="comSearchInput"
								v-model="selectTimeComm"
								type="datetimerange"
								range-separator="至"
								align="center"
								start-placeholder="开始日期"
								end-placeholder="结束日期"
								@change="changeTimeComm"
								:default-time="['00:00:00', '00:00:00']">
							</el-date-picker>
						</div>
						<!-- <el-button style="width:1.5rem;" type="primary" @click="()">查询</el-button> -->
						<div class="search_btn" v-if="hasApi('queryCampusAccountRecord')" @click="apiQueryCampusAccountRecord()">搜索</div>
					</div>
					<div class="orderObj" v-for="(row,index) in campusAccountRecordCommData.tableData" :key="index">
						<div class="row" style="border-bottom: 0.01rem solid #ebebeb;height:0.35rem;">
							<span>订单号：{{row.acOrderEntity.orderNo}}</span>
							<span style="margin-left:1rem;">下单时间：{{row.acOrderEntity.orderDate}}</span>
							<span v-if="allordersObj.orderType!='退款订单'" style="margin-left:1rem;">最近支付时间：{{row.accountDate}}</span>
							<span v-else style="margin-left:1rem;">退款时间：{{row.accountDate}}</span>
						</div>
						<div class="courseinfo">
							<div class="cloumn namebox" style="width:35%;">
								<span class="className">{{row.acOrderEntity.className}}</span>
								<span>老师类型：{{foreignTeacherTypeMatch[row.acOrderEntity.foreignTeacherType]}}</span>
								<!-- <span>班级名称：天才少年班</span> -->
							</div>
							<div class="cloumn" style="width:20%;">
								<span>
									<span v-if="allordersObj.orderType!='退款订单'" >
										<span>已约</span>
										<span style="color:#3885F8;margin:0 0.05rem;">{{row.acOrderEntity.buySyllabusNum}}</span>
									</span>
									<span v-else >
										<span>已退</span>
										<span style="color:#3885F8;margin:0 0.05rem;">{{row.acOrderRefundEntity.syllabusNum}}</span>
									</span>
									<span>节/共</span>
									<span style="margin:0 0.05rem;">{{row.acOrderEntity.syllabusNum}}</span>
									<span>节</span>
								</span>
							</div>
							<div class="cloumn" style="width:20%;">
								<span>
									<span v-if="allordersObj.orderType!='退款订单'">共支付</span>
									<span v-else>共退款</span>
									<span style="color:#ff7901;margin:0 0.05rem;font-size:0.22rem;">￥{{row.accountMoney}}</span>
								</span>
							</div>
							<div class="cloumn" style="width:10%;">
								<span style="color:#3885F8;">{{allordersObj.orderType}}</span>
							</div>
							<div class="cloumn" style="width:15%;">
								<span>{{row.campusName}}</span>
							</div>
						</div>
					</div>
					<div class="row" style="text-align:center;">
						<el-pagination
							:page-sizes="[10, 20, 30, 40,50,100]"
							:page-size="campusAccountRecordSearchParam.pageSize"
							layout="total, sizes, prev, pager, next, jumper"
							:current-page="campusAccountRecordSearchParam.currPage"
							:total="campusAccountRecordCommData.paginationtotal"
							@current-change="commCurrentPageChange"
							@size-change="commhandleSizeChange">
						</el-pagination>
					</div>
				</div>
			</div>
		</div>

		<!-- 校区账单详情 -->
		<el-dialog class="schoolAccountDetailPopup" :modal="false" :title="'校区账单'" :visible.sync="schoolAccountDetailPopupVisible">
			<schoolAccountDetail ref="schoolAccountDetail">
			</schoolAccountDetail>
		</el-dialog>
		<!-- 校区充值 -->
		<el-dialog class="schoolRechargePopup" :modal="false" :title="'校区充值'" :visible.sync="schoolRechargePopupVisible"
			:close-on-click-modal="false">
			<schoolRecharge ref="schoolRecharge" @cancel="schoolRechargePopupVisible=false;" @chargeOk="init()">
			</schoolRecharge>
		</el-dialog>
	</div>
</template>

<script>
	import schoolAccountDetail from './common/school_account_detail'
	import schoolRecharge from './common/school_recharge'
	let vm;
	export default{
		components:{schoolAccountDetail,schoolRecharge},
		// props:[''],
		data(){
			return {
				mainTitle:'账户中心',
				headradioBtn_type:{
					radio:'account'
				},
				schoolNameOptionsComm:[],
				selectSchoolComm:'',
				selectTimeComm:null,
				campusAccountRecordSearchParam:{
					campusId:'',
					accountType:0,
					// startTime:'',
					// endTime:'',
					pageSize:10,
					currPage:1
				},
				campusAccountRecordCommData:{
					tableData: [],
					paginationtotal:0,
				},
				// activePane:'account',
				/**利用disableOperationByRole函数匹配后得到，可将其他角色归类至userLevel
				 * @param 1: 默认为机构
				 * @param 2：默认为校区
				 */
				userLevel:-1,
				accountObj:{
					accountMoney:0,
					organization:{
						searchParam:{
							pageSize:10,
							currPage:1,
							total:0,
							orgId:'',
							generalTerm:'',
							cooperationMode: ""
						},
						tableData: [],
					},
					school:{
						tableData: [],
						paginationtotal:0,
					},
				},
				chargeObj:{
					selectSchool: '',
					startTime:'',
					endTime:'',
					tableData: [],
					paginationtotal:0,
				},
				payObj:{
					selectSchool: '',
					inputClassName:'',
					startTime:'',
					endTime:'',
					tableData_org: [],
					tableData_school: [],
					paginationtotal:0,
				},
				refundObj:{
					selectSchool: '',
					inputClassName:'',
					startTime:'',
					endTime:'',
					tableData: [],
					paginationtotal:0,
				},
				allordersObj:{
					orderType:'交易成功',
					selectSchool: '',
					startTime:'',
					endTime:'',
					courseList:[],
					paginationtotal:0,
					currPage:1
				},
				schoolAccountDetailPopupVisible:false,
				schoolRechargePopupVisible:false,
				accountPayModeMatch:{},
				foreignTeacherTypeMatch:{},
			};
		},
		methods:{
			init(){
				this.headradioBtn_type.radio='account';
				this.accountObj.organization.searchParam.generalTerm='';
				this.schoolAccountDetailPopupVisible=false;
				this.schoolRechargePopupVisible=false;
				this.mainTitle='账户中心';
				if(this.userLevel==1){//机构管理员
					this.apiQueryOrgMoney();
					this.apiGetSchoolList();
					this.apiQuerySchoolsMoney(1);
				}
				else if(this.userLevel==2){//校区管理员
					this.apiQueryCurrentShoolMoney();
					//充值记录
					this.campusAccountRecordSearchParam={
						campusId:this.$store.state.campusId,
						accountType:1,
						pageSize:10,
						currPage:1
					};
					this.apiQueryCampusAccountRecord();
				}
			},
			/**查询机构余额 */
			apiQueryOrgMoney(){
				api.orgInfo({orgId:this._userInfo.orgId}).then(function(d){
					// debugger
					if(d.result=='操作成功'){
						vm._orgInfo=d.organization;
						vm.accountObj.accountMoney=vm._orgInfo.accountMoney;
					}
				});
			},
			schoolListCurrentPageChange(val){
				this.apiQuerySchoolsMoney(val);
			},
			schoolListSizeChange(val){
				this.accountObj.organization.searchParam.pageSize=val;
				this.apiQuerySchoolsMoney(1);
			},
			apiQueryCurrentShoolMoney(){
				//校区余额
				api.campusInfo({campusId:this.$store.state.campusId}).then(function(d){
					if(d.result=='操作成功'){
						vm.accountObj.accountMoney=d.campus.accountMoney||0;
					}
				});
			},
			/**查询各校区余额 */
			apiQuerySchoolsMoney(pgIndex){
				this.accountObj.organization.searchParam.currPage=pgIndex||this.accountObj.organization.searchParam.currPage;
				this.accountObj.organization.searchParam.orgId=this._userInfo.orgId;
				api.campusListPage(this.accountObj.organization.searchParam).then(function(d){
					// debugger
					if(d.resultCode==2000){
						vm.accountObj.organization.tableData=d.list;
						vm.accountObj.organization.searchParam.total=d.totalCount;
					}
				});
			},
			/**获取所有机构下所有校区 */
			apiGetSchoolList(){
				api.campusListByOrg({orgId:this._userInfo.orgId}).then(function(d){
					// debugger
					if(d.result=='操作成功'){
						vm._schoolList=d.list;
						// vm.accountObj.organization.tableData=d.list;

						vm.schoolNameOptionsComm=[];
						vm._schoolList.forEach(element => {
							vm.schoolNameOptionsComm.push({
								value:element.campusId,
								label:element.name
							});
						});
					}
				});
			},
			/**查询校区下的充值、支出、退费记录
			 * @param campusId
			 * @param accountType 收支类别：全部-0；充值-1；支出-2；退款-3
			 * @param startTime
			 * @param endTime
			 * @param pageSize
			 * @param currPage
			 */
			apiQueryCampusAccountRecord(pageNum){
				this.campusAccountRecordSearchParam.currPage=pageNum||1;
				api.queryCampusAccountRecord(this.campusAccountRecordSearchParam).then(function(d){
					if(d.result=='操作成功'){
						if(d.list){
							d.list.forEach(ele=>{
								if(!ele.acOrderRefundEntity)ele.acOrderRefundEntity={};
							});
						}
						vm.campusAccountRecordCommData.tableData=d.list;
						vm.campusAccountRecordCommData.paginationtotal=d.totalCount;
					}
				});
			},
			headradioBtnchange_type(d){
				// this.activePane=d;
				let match={'account':'账户中心','charge':'充值明细','pay':'支出明细','refund':'退款明细','allorders':'全部订单'};
				this.mainTitle=match[d];
				if(this.userLevel==1){
					if(d=='account'){
						this.accountObj.organization.searchParam.generalTerm='';
						this.apiQueryOrgMoney();
						this.apiGetSchoolList();
						this.apiQuerySchoolsMoney(1);
					}
					else if(d=='charge'){
						this.campusAccountRecordSearchParam={
							// campusId:this.$store.state.campusId,
							accountType:1,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
					else if(d=='pay'){
						this.campusAccountRecordSearchParam={
							// campusId:this.$store.state.campusId,
							accountType:2,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
					else if(d=='refund'){
						this.campusAccountRecordSearchParam={
							// campusId:this.$store.state.campusId,
							accountType:3,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
					else if(d=='allorders'){
						this.allordersObj.orderType='交易成功';
						// this.allordersObj.currPage=1;
						this.campusAccountRecordSearchParam={
							// campusId:this.$store.state.campusId,
							accountType:2,
							pageSize:10,
							currPage:1,
							isSaleSuccess:1
						};
						this.apiQueryCampusAccountRecord();
					}
				}
				else if(this.userLevel==2){
					if(d=='account'){
						//充值记录
						this.campusAccountRecordSearchParam={
							campusId:this.$store.state.campusId,
							accountType:1,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
					else if(d=='charge'){
						this.campusAccountRecordSearchParam={
							campusId:this.$store.state.campusId,
							accountType:1,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
					else if(d=='pay'){
						this.campusAccountRecordSearchParam={
							campusId:this.$store.state.campusId,
							accountType:2,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
					else if(d=='refund'){
						this.campusAccountRecordSearchParam={
							campusId:this.$store.state.campusId,
							accountType:3,
							pageSize:10,
							currPage:1
						};
						this.apiQueryCampusAccountRecord();
					}
				}
				this.selectSchoolComm='';
				this.selectTimeComm=null;
				this.payObj.inputClassName=null;
				this.refundObj.inputClassName=null;
				this.schoolAccountDetailPopupVisible=false;
				this.schoolRechargePopupVisible=false;
			},
			campusChange : function(campusId) { //校区改变
				if(this.userLevel==2)
					this.init();
			},
			/**根据角色权限限制操作 */
			disableOperationByRole() {
				switch (this._userInfo.roleMode) {
					//超级管理员
					case 0: {
					
						break;
					}
					//机构管理员
					case 1: {
						this.userLevel=1;
						break;
					}
					//校区管理员
					case 2: {
						this.userLevel=2;
						break;
					}
				}
				// console.log(this.userLevel)
			},
			/**校区账单详情 */
			showSchoolAccountDetail(data){
				this.schoolAccountDetailPopupVisible=true;
				if(this.$refs.schoolAccountDetail){
					this.$refs.schoolAccountDetail.initByData(data,vm._schoolList);
				}
				else{
					this.$nextTick(()=>{
						this.$refs.schoolAccountDetail.initByData(data,vm._schoolList);
					});
				}
			},
			/**校区充值 */
			showSchoolRecharge(){
				this.schoolRechargePopupVisible=true;
				if(this.$refs.schoolRecharge){
					this.$refs.schoolRecharge.initByData(vm._schoolList,{username:this._userInfo.username,nickName:this._userInfo.nickName});
				}
				else{
					this.$nextTick(()=>{
						this.$refs.schoolRecharge.initByData(vm._schoolList,{username:this._userInfo.username,nickName:this._userInfo.nickName});
					});
				}
			},
			/**支出明细、退款明细-订单详情 */
			payRefundDetail(data){
				// this.activePane='allorders';
				this.headradioBtn_type.radio='allorders';
			},
			accountSearchBySchoolName(d){
				if(d.trim()==''){
					this.accountObj.organization.tableData=vm._schoolList;
					return;
				}
				let result=[];
				vm._schoolList.forEach(element => {
					if(element.name.includes(d)){
						result.push(element);
					}
				});
				this.accountObj.organization.tableData=result;
			},
			commCurrentPageChange(d){
				this.apiQueryCampusAccountRecord(d);
			},
			commhandleSizeChange(val){
				this.campusAccountRecordSearchParam.pageSize=val;
				this.campusAccountRecordSearchParam.currPage=1;
				this.apiQueryCampusAccountRecord();
			},
			commSelectSchool(d){
				if(!d){
					let newparam={};
					for(let k in this.campusAccountRecordSearchParam){
						if(k=='campusId')continue;
						newparam[k]=this.campusAccountRecordSearchParam[k];
					}
					this.campusAccountRecordSearchParam=newparam;
				}
				else
					this.campusAccountRecordSearchParam.campusId=d;
			},
			changeTimeComm(d){
				let start,end;
				if(d)
				{
					start=tool.DateToString(d[0], "yyyy-MM-dd HH:mm");
					end=tool.DateToString(d[1], "yyyy-MM-dd HH:mm");
					this.campusAccountRecordSearchParam.startTime=start;
					this.campusAccountRecordSearchParam.endTime=end;
				}
				else{
					let newparam={};
					for(let k in this.campusAccountRecordSearchParam){
						if(k=='startTime'||k=='endTime')continue;
						newparam[k]=this.campusAccountRecordSearchParam[k];
					}
					this.campusAccountRecordSearchParam=newparam;
				}
			},
			selectClassName(d){
				if(!d){
					let newparam={};
					for(let k in this.campusAccountRecordSearchParam){
						if(k=='className')continue;
						newparam[k]=this.campusAccountRecordSearchParam[k];
					}
					this.campusAccountRecordSearchParam=newparam;
				}
				else
					this.campusAccountRecordSearchParam.className=d;
			},
			allorderChangeType(d){
				let match={'交易成功':2,'支付成功':2,'退款订单':3};
				this.campusAccountRecordSearchParam.accountType=match[d];
				this.campusAccountRecordSearchParam.currPage=1;
				// this.allordersObj.currPage=1;
				this.selectSchoolComm='';
				this.selectTimeComm=null;	
				this.changeTimeComm(null);
				this.commSelectSchool(null);
				if(d=='交易成功'){
					this.campusAccountRecordSearchParam.isSaleSuccess=1;
					this.apiQueryCampusAccountRecord();
				}
				else
				{
					let newparam={};
					for(let k in this.campusAccountRecordSearchParam){
						if(k=='isSaleSuccess')continue;
						newparam[k]=this.campusAccountRecordSearchParam[k];
					}
					this.campusAccountRecordSearchParam=newparam;
					this.apiQueryCampusAccountRecord();
				}
				
			}
		},
		mounted(){
			vm=this;
			this._userInfo = tool.getItem(lsKey.user, true); //得到当前用户信息
			this.accountPayModeMatch=tool.getDictNameByValue(-100,'account_pay_mode',false);
			this.foreignTeacherTypeMatch=tool.getDictNameByValue(-100,'foreign_teacher_type',false);

			// debugger
			this.disableOperationByRole();
			this.init();
		},
		computed:{
			
		},
		watch:{

		}
	}
</script>

<style lang="scss">
	#account_center{
		color: #333333;
		.headmenu{
			.el-tabs__header{
				display: none !important;
			}
			.el-tabs__item{
				font-size: 0.25rem !important;
				height: 0.6rem !important;
				line-height: 0.6rem !important;
			}
		}
		.headradioBtn_type{
			width: 8rem;
			position: absolute;
			top: -0.8rem;
			left: .45rem;
			.el-radio-button{
				margin-left: 0.2rem !important;
			}
			.el-radio-button.first{
				margin-left: 0rem !important;
			}
			.el-radio-button__inner{
				width: 1.2rem !important;
				// border-top: 0;
				// border-bottom: 0;
				height: 0.60rem !important;
				line-height: 0.25rem !important;
				font-size: 0.18rem !important;
				border: unset !important;
				border-radius:unset !important;
				background: unset !important;
				color: unset !important;
				line-height: 0.45rem !important;
    			font-size: 0.2rem !important;
			}
			.el-radio-button__orig-radio:checked + .el-radio-button__inner{
				box-shadow:unset !important;
				font-weight: bold !important;
				border-bottom: 0.03rem solid #3885f8 !important;
			}

		}
		.main-title{
			margin:  0.25rem auto;
			min-width: 15.48rem;
			width: 15.48rem;
			margin-top: 0.34rem;
			width: 15.48rem;
			font-size: 0.25rem;
			font-weight: bold;
		}
		.box-chargeForSchool{
			margin:  0.2rem auto;
			margin-bottom: 0;
			min-width: 15.48rem;
			width: 15.48rem;
			padding: 0 0.66rem;
			height: 1.9rem;
			background: rgb(65,137,245);
			border: 0.01rem solid #ededed;
			border-radius: 0.10rem;
			box-shadow: 0 0.02rem 0.04rem 0 #3885f81f, 0 0 0.04rem 0 #3885f81f;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.box-accountMoney{
				width: 8rem;
				height: 50%;
				color: #FFFFFF;
				display: flex;
				flex-wrap: wrap;
			}
			.box-payBtn{
				// height: 50%;
				.el-button{
					width: 2.18rem !important;
					height: 0.48rem !important;
					background-color: transparent !important;
					color: #FFFFFF !important;
					font-size: 0.22rem !important;
				}
			}
		}
		.content{
			margin:  0.2rem auto;
			min-width: 15.48rem;
			width: 15.48rem;
			padding: 0.2rem 0.32rem 0.2rem 0.32rem;
			height: auto;
			background: #fff;
			border: 0.01rem solid #ededed;
			border-radius: 0.10rem;
			box-shadow: 0 0.02rem 0.04rem 0 #3885f81f, 0 0 0.04rem 0 #3885f81f;
			.box-innerPane{
				width: 100%;
				min-height: 4.7rem;
				padding: 0 0.16rem;
				.row{
					width: 100%;
					min-height: 0.16rem;
					margin: 0.08rem 0;
				}
				.orderObj{
					width: 100%;
					padding: 0.16rem 0.3rem;
					margin-bottom: 0.14rem;
					background: #fff;
					border: 0.01rem solid #dcdfe6;
					border-radius: 0.1rem;
					-webkit-box-shadow: 0 0.02rem 0.38rem 0 #3885f81f, 0 0 0.06rem 0 #3885f81f;
					box-shadow: 0 0.02rem 0.38rem 0 #3885f81f, 0 0 0.06rem 0 #3885f81f;
					.courseinfo{
						display: flex;
						margin-bottom: 0.12rem;
						.cloumn{
							width: 15%;
							display: flex;
							justify-content: center;
							align-items: center;
						}
						.namebox{
							display: flex;
							flex-direction: column;
							align-items: flex-start;
    						padding-left: 0.1rem;
							.className{
								margin-bottom: 0.05rem;
								font-size: 0.22rem;
								font-weight: bold;
							}
						}
					}
				}
				.orderObj.searchbox{
					display: flex;
					justify-content: space-between;
				}
				.orderType{
					.el-radio-button__inner{
						font-size: 0.18rem !important;
					}
					.el-radio-button.first{
						margin-left: 0rem !important;
					}
					.el-radio-button__inner{
						width: 1.2rem !important;
						// border-top: 0;
						// border-bottom: 0;
						height: 0.60rem !important;
						line-height: 0.25rem !important;
						font-size: 0.18rem !important;
						border: unset !important;
						border-radius:unset !important;
						background: unset !important;
						color: unset !important;
						line-height: 0.45rem !important;
						font-size: 0.2rem !important;
					}
					.el-radio-button__orig-radio:checked + .el-radio-button__inner{
						box-shadow:unset !important;
						font-weight: bold !important;
						border-bottom: 0.03rem solid #3885f8 !important;
					}
				}
			}
		}
		.content.allorders{
			padding: 0;
			background: transparent;
			border: 0;
			// border-radius: 0.10rem;
			box-shadow: none;
			.box-innerPane{
				padding: 0;
			}
		}
		.el-table,.el-button,.el-input,.el-pager li{
			font-size: 0.16rem !important;
		}
		//弹窗
		.schoolAccountDetailPopup.el-dialog__wrapper {
			top: 0.81rem !important;
			left: 2.1rem !important;
			background: rgba(0,0,0,0.5);
			z-index: 30 !important;
		}
		.schoolRechargePopup.el-dialog__wrapper {
			top: 0.81rem !important;
			left: 2.1rem !important;
			background: rgba(0,0,0,0.5);
			z-index: 30 !important;
		}

		//鼠标悬浮
		.hoverpointer:hover{
			cursor: pointer;
		}
		// 滚动条
		.scrollbarstyle::-webkit-scrollbar {
			width: 0.05rem;
		}
		.scrollbarstyle::-webkit-scrollbar-thumb {
			border-radius: 0.5rem;
			background: #BBBBBB;
		}
		.scrollbarstyle::-webkit-scrollbar-track {
			background: #F2F6FC;
		}
		.el-table__body-wrapper::-webkit-scrollbar {
			width: 0.05rem;
		}
		.el-table__body-wrapper::-webkit-scrollbar-thumb {
			border-radius: 0.5rem;
			background: #BBBBBB;
		}
		.el-table__body-wrapper::-webkit-scrollbar-track {
			background: #F2F6FC;
		}
	}
	// 搜索框样式
	.comSearchInput .el-input__inner {
		background-color: #f7f8fa;
		border-radius: 0.08rem;
		font-size: 0.16rem;
		color: #666666;
		height: 0.36rem !important;
		line-height: 0.36rem !important;
	}
	.comSearchInput.el-input__inner {
		background-color: #f7f8fa;
		border-radius: 0.08rem;
		font-size: 0.16rem;
		color: #666666;
		height: 0.36rem !important;
		line-height: 0.36rem !important;
		padding: 0 0.1rem !important;
		.el-range-input{
			font-size: 0.16rem !important;
			color: #666666 !important;
			background-color: #f7f8fa !important;
		}
	}
</style>